# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=jasper
pkgver=4.2.4
pkgrel=0
pkgdesc="Software-based implementation of the codec specified in the emerging JPEG-2000 Part-1 standard"
url="https://www.ece.uvic.ca/~mdadams/jasper/"
arch="all"
license="custom:JasPer2.0"
makedepends="
	cmake
	samurai
	"
checkdepends="bash"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/mdadams/jasper/releases/download/version-$pkgver/jasper-$pkgver.tar.gz"

build() {
	# The directory "build" already exists in the repo
	cmake -B build-jasper -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_RPATH=ON \
		-DJAS_ENABLE_OPENGL=ON \
		-DJAS_ENABLE_LIBJPEG=ON \
		-DALLOW_IN_SOURCE_BUILD=ON
		# We're not actually building in source, the check is wrong so overwrite it
	cmake --build build-jasper
}

check() {
	# Add libjasper.so.* to LD_LIBRARY_PATH so it can be found
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$builddir"/build-jasper/src/libjasper
	ctest --test-dir build-jasper -E "run_test_3"
}

package() {
	DESTDIR="$pkgdir" cmake --install build-jasper
}

sha512sums="
54af8813afddafffdddc7bd8b8eb5ac90ff73fb28aa4b8d77e4d5e1231fd05e4052f843912c4b3dac6e8ab286e97248d900e8541577642016e2a0049eb707ec9  jasper-4.2.4.tar.gz
"
